feat: update DevContext and LSP to support composable schemas#2965
feat: update DevContext and LSP to support composable schemas#2965tstirrat15 wants to merge 2 commits intomainfrom
Conversation
cffe476 to
e20db9f
Compare
Codecov Report❌ Patch coverage is ❌ Your project check has failed because the head coverage (74.80%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2965 +/- ##
==========================================
- Coverage 74.82% 74.80% -0.02%
==========================================
Files 497 498 +1
Lines 60656 60868 +212
==========================================
+ Hits 45382 45526 +144
- Misses 12115 12166 +51
- Partials 3159 3176 +17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
3998ee0 to
e20db9f
Compare
2fbc435 to
9ef3b65
Compare
9ef3b65 to
5dcc950
Compare
12bc73d to
a1130f6
Compare
254aa41 to
10d5e84
Compare
| return hoverContents, nil | ||
| } | ||
|
|
||
| func (s *Server) textDocDefinition(_ context.Context, r *jsonrpc2.Request) (*lsp.Location, error) { |
There was a problem hiding this comment.
FYI this is what gets called in Vs Code when you click F12/Go to Definition
|
|
||
| // Get errors. | ||
| for _, devErr := range devErrs.GetInputErrors() { | ||
| if !slices.Contains(devErr.Path, string(uri)) { |
There was a problem hiding this comment.
FYI this code gets called in VSCode when you save a file.
devErrs contains errors from ALL files,.
However, computeDiagnostics is only computing errors for uri.
| } | ||
| if derr != nil { | ||
| return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInternalError, Message: derr.String()} | ||
| return nil, errors.New(derr.String()) |
There was a problem hiding this comment.
FYI otherwise this get shown in the error console but not to the user
|
|
||
| // ParameterTypeString returns the string form of the type reference. | ||
| func ParameterTypeString(typeRef *core.CaveatTypeReference) string { | ||
| if typeRef == nil { |
There was a problem hiding this comment.
FYI prevents a panic in line 73. Can move to different PR if so desired
| Context: errWithSource.SourceCodeString, | ||
| Line: lineNumber, | ||
| Column: columnPosition, | ||
| Path: []string{path}, |
There was a problem hiding this comment.
FYI zed uses this to show the correct content from the file that has the error
4eeb6c9 to
fe72591
Compare
…d support for textDocument/definition, support composable schemas). fix position mapper
fe72591 to
dae057f
Compare
Description
Filesystem-aware development system — The DevContext and schema compilation now accept a filesystem
(fs.FS), enabling validation of schemas that use import syntax (composable schemas).
Key changes:
pkg/development/— devcontext.go and schema.go updated to thread an fs.FS through schemacompilation. The position mapper (
schema_position_mapper.go) was reworked significantly tohandle multi-file schemas correctly, with new tests.
pkg/schemadsl/compiler/— The importer and position mapper now work with filesystem-backedsources. development.go gained helpers for filesystem-aware compilation. The translator
tracks source file information more precisely.
LSP (internal/lsp/)— New overlay filesystem (overlay.go) lets the LSP validate open/unsaved filesby layering in-memory content over the real filesystem. Handlers updated to support
textDocument/definition(go-to-definition) and fixrequestDiagnostics. Substantial new tests.Testing
you can test this by bringing it over to VSCode and trying it out with schemas of your own. you have to
On spicedb repo: gh pr checkout 2965 && mage build:binary
On vscode repo : gh pr checkout 51
edit line 95 on package.json to point to the binary you created in step 1
hit F5 to run the extension
if you want to test in zed:
On zed repo: gh pr checkout 635 && mage build:binary
you can now do ./zed validate ....